package com.hisense.ovcloud.apicontrol.errors;

public enum SystemError {

    SYSERROR(100001, "System Error"),
    SERVICEUNAVAILABLE(100002, "服务暂停"),
    REMOTESERVICEERROR(100003, "远程服务错误"),
    IPLIMIT(100004, "请求来自未经授权的IP地址"),
    REFERLIMIT(100005, "来自该refer的请求无访问权限"),
    PARAMERROR(100006, "request params error, please check API doc"),
    SYSTEMBUSY(100007, "任务过多，系统繁忙"),
    JOBEXPIRE(100008, "任务超时"),
    RPCERROR(100009, "RPC Call Error : %s"),
    ILLEGALREQUEST(100010, "非法请求"),
    INVALIDUSER(100011, "不合法的用户"),
    INSUFFAPPPERMISSION(100012, "应用的接口访问权限首先"),
    PARAMINVALID(100014, "Parameter Error : %s"),
    MISSPARAM(100013, "Missing Required Arguments : %s"),
    REQUESTOVERLIMIT(100015, "请求长度超过限制"),
    REQUESTNOTFOUND(100016, "接口不存在"),
    HTTPMETHODERROR(100017, "The requested HTTP method is not supported. Please check if the correct POST/GET method is selected"),
    IPREQUESTLIMIT(100018, "IP请求频次超过上限"),
    USERREQUESTLIMIT(100019, "用户请求频次超过上限"),
    USERREQUESTLIMITSPECIAL(100020, "用户请求特殊接口 (%s) 频次超过上限"),
    APPKEYPERMISSIONDENIED(100021, "该资源需要appkey拥有授权"),
    INTERNALQUERYERROR(100022, "内部查询错误"),
    COMMUNICATIONERROR(100023, "网络通信失败:%s"),
    //应用认证失败,无法获取appCode
    APPLICATIONVERIFYERROR(100024, "Application authentication failed, unable to obtain platformId"),
    AOPERROR(100025, "%s AOP调用错误"),
    ACCESSTOKENERROR(100026, "AccessToken Invalid"),
    ACCESSTOKENPARSEERROR(100027, "AccessToken Parse Failed"),
    ACCESSUNABLEVERIFY(100028, "AccessToken验证失败"),
    RPCCOMMERROR(100029, "RPC通信错误:%s"),
    ACCESSTOKENNOTEXIST(100030, "AccessToken不存在"),
    ANONIMOUSSUBSCRIBER(100031, "当前API不允许匿名访问"),
    APPINBLACKLIST(100032, "当前应用被列入黑名单"),
    DEVELOPERAUTHERROR(100033, "开发者权限不足"),
    SUBSCRIBERAUTHERROR(100034, "用户未授权"),
    APINOTINGROUP(100035, "当前api不在允许的api分组中"),
    APIACCESSCOUNTERROR(100036, "Api访问次数超过限制"),
    APIINFONOTEXIST(100037, "Api信息不存在"),
    APPINFONOTEXIST(100038, "应用信息不存在"),
    APICODEGETERROR(100039, "获取ApiCode失败"),
    VERIFYSIGNATUREERROR(100040, "params verify Fail"),
    UNSUPPORTEDCONTENTTYPE(100041, "Unsupported Content-Type."),
    INVALIDAPPID(100042, "Invalid appKey"),

    SECURITYDECRYPT(100043, "Cannot use GET request for this function >= version 7.0, please use POST method instead"),
    APPSCRETNOTPERMITTED(100044, "Cannot use appSecret in parameters >= version 7.0, only appId is permitted to use"),
    REQUEST_MUST_CRYPT(100045, "The request parameters should be encrypted by AES256-CBC method"),
    RESPONSE_MUST_CRYPT(100046, "This response parameters should be encrypted by AES256-CBC method"),

    ACCESSTOKEN_CANNOT_BOTH_IN_HEADER_URL(100047, "accessToken cannot both exist in header and url!"),
    ACCESSTOKEN_NOT_IN_HEADER(100050, "accessToken of GET request must in header after 7.0!"),

    THIS_APPID_NOT_PERMITED(100048, "this appId isn't allowed to visit this url!"),
    PUID_CHECK_FAILED_NO_WIFIID_PERMITED(100049, "no wifiid parameter permitted!");

    private int code;
    private String desc;
    private String desc1;

    SystemError(int code, String desc) {
        this.code = code;
        this.desc = desc;
        this.desc1 = desc;
    }

    SystemError() {
    }

    public int value() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String desc(String param) {
        return String.format(this.desc1, param);
    }

    public SystemError getError(String param) {
        this.desc = String.format(this.desc1, param);
        return this;
    }
}
